package com.itheima.d5_resource;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/*
     目标：掌握释放资源的方式。
     try(){}catch(){}
 */
public class Test2 {
    public static void main(String[] args)  {
        try (FileInputStream fis = new FileInputStream("a.png");
             FileOutputStream fos = new FileOutputStream("b.png")
        ){
            int len;
            byte[] bytes = new byte[1024];
            while ((len = fis.read(bytes)) != -1) {
                fos.write(bytes, 0, len);
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
